<?php
date_default_timezone_set('Europe/Paris');
require_once 'lib/krumo/class.krumo.php';
require_once 'lib/jsondb/json.db.php';
$db = new JsonDB("db.json");

if (isset($_POST['who']) && isset($_POST['nb']))
{
    $who = $_POST['who'];
    $nb = $_POST['nb'];
    $db->set($who, $nb)->save();
}

// krumo($db->data);
?>
<!DOCTYPE html>
<html class="no-js">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>Roulette [Beta]</title>
        <link rel="stylesheet" href="css/main.css">
        <link rel="stylesheet" href="css/isotope.css">
        <link rel="stylesheet" href="css/jquery.vegas.css">
        <script src="js/vendor/modernizr-2.6.2.min.js"></script>
    </head>
    <body>


        <div class="container">

            <!-- Main hero unit for a primary marketing message or call to action -->
            <div class="hero-unit">

                <h1>Pokroulette</h1>

                <p>Qui prendra la photo du jour ?</p>


                <a class="btn-primary">Tirer au sort !</a>


                <div id="zotop-container" class="clickable clearfix">

                    <?php
                    $persons = array(
                        'Ro,Romain,lightsteelblue',
                        'Am,Anne-Marie,navajowhite',
                        'Ka,Karim,lightpink',
                        'Je,Jean-Ga,steelblue',
                        'Re,R&eacute;gis,lightgreen',
                        'Fh,Florent H.,lightblue',
                        'Fj,Florent J.,lightsalmon',
                        'Er,Eric,lightseagreen',
                        'Ja,Jacques,lightcoral'
                    );
                    shuffle($persons);
                    $colors = array('red', 'black', 'green');
                    ?>

                    <?php foreach ($persons as $person) : ?>

                        <?php list($key, $name, $color) = explode(',', $person) ?>

                        <div class="element <?php echo $colors[array_rand($colors)] ?>">
                            <p class="symbol"   ><?php echo $key ?>             </p>
                            <p class="name"     ><?php echo $name ?>            </p>
                            <p class="weight"   ><?php echo $db->data->$key ?>  </p>
                        </div>

                    <?php endforeach; ?>

                </div>

            </div>

            <footer>
                <p>&copy; Racam 2012</p>
            </footer>

        </div> <!-- /container -->

        <script src="js/vendor/jquery-1.10.1.min.js"></script>
        <script src="js/vendor/jquery.isotope.min.js"></script>
        <script src="js/vendor/jquery.vegas.js"></script>
        <script src="js/main.js"></script>
    </body>
</html>
